﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_User : System.Web.UI.Page
{
    UserBusiness ub = new UserBusiness();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bindGV();
        }
    }
    public void bindGV()
    {
        GridView1.DataSource = ub.getAllUser();
        GridView1.DataBind();
    }

    
    protected void btnAddNewUser_Click(object sender, EventArgs e)
    {
        Response.Redirect("UserEdit.aspx?userID=0");
    }
    
    protected void lbDelete_Click(object sender, EventArgs e)
    {
        if (!ub.Delete (int.Parse(((LinkButton)sender).CommandArgument)))
            Label1.Text = "Can't delete";
        Response.Redirect("User.aspx");

    }

    protected void lbEdit_Click(object sender, EventArgs e)
    {
        Response.Redirect("UserEdit.aspx?userID="+((LinkButton)sender).CommandArgument);
    }
}